from odoo import api, fields, models, _


class Collect(models.Model):
    _name = 'check.collectback'
    _description = "收退押金"


    # 房间信息

    house_id = fields.Many2one(
        'check.house',
        '当前房号',
    )

    # 房间状态
    stage = fields.Boolean(
        '房间状态',
        related='house_id.Stage',
    )
    guest_id = fields.Many2one(
        related='house_id.guest_id',
        string='主客姓名'
    )

    # 进店时间
    In_Time = fields.Date(
        "进店时间",
    )

    Money = fields.Monetary(
        "押金总额",
        'currency_id',
        related='guest_id.Money'
    )


    live_time = fields.Integer(
        related='guest_id.live_day',
        string="入住时长",
    )

    unit_price = fields.Monetary(
        "入住单价",
        'currency_id',
        related='house_id.pre_price'
    )

    leave_time = fields.Date(
        string="预离时间",
        related='guest_id.leave_day'
    )

    total_consume = fields.Monetary(
        "消费总额",
        'currency_id',
        related='guest_id.Total_consume'
    )

    receive_money = fields.Monetary(
        "收款金额",
        'currency_id',

    )

    next_day = fields.Integer(
        "续住天数(天)",
        default=2
    )

    way = fields.Selection(
        [
            ('0', '支付宝')
        ]
        , default="0", string="收款方式"
    )

    note = fields.Char('备注信息')

    currency_id = fields.Many2one(
        'res.currency',
    default = lambda self: self.env.user.company_id.currency_id)

